import time


# 把需要添加的新功能都写到wrapper里面
def cal_time(func):
    def inner():
        start = time.time()
        s = func()
        end = time.time()
        print('耗费时间：', end - start)
        return s

    return inner


@cal_time
def demo():
    x = 0
    for i in range(1, 10000000):
        x += i
    return x


z = demo()  # 此时的demo函数已经变为了inner函数
print(z)
